<!DOCTYPE html>
<html lang="en" class="no-js">
    <head>
        <meta charset="utf-8">
        <title>注册</title>
		<meta name="keywords" content="" />
		<meta name="description" content="" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- CSS -->
        <link rel="stylesheet" href="__PUBLIC__/assets/css/reset.css">
        <link rel="stylesheet" href="__PUBLIC__/assets/css/supersized.css">
        <link rel="stylesheet" href="__PUBLIC__/assets/css/style.css">

        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
     </head>

    <body>

        <div class="page-container">
            <h1>注册</h1>
            <form action="{:U('User/registdo')}" method="post">
            	  	 <select class="Select" id="doc-select-1" name='type' onchange="typechange();">
            	  		<option value="1">学生</option>
            	  		<option value="2">老师</option>
            	  		<option value="3">企业</option>
            	    </select>
            	  		<input type="text" id="send-sms-mobile" name="phone" pattern="^1[34578]\d{9}$"  data-foolish-msg="输入正确的手机号" class="username" placeholder="请输入手机号" required>
                        <div id="sms-module">
                            <p class="top15 captcha" id="captcha-container">  
                                <input name="verify"  class="captcha-text" placeholder="验证码" id="imgcode" type="text" style="width:50%;float:left;" > 
                                <img width="30%" class="left15" height="40" alt="验证码" src="{:U('Home/Index/verify_c',array())}" title="点击刷新" style="margin-top:30px;">  
                            </p> 
                            <p>
                                <input type="text" name="send-sms-code" id="send-sms-code" placeholder="手机验证码" style="width:50%;float:left;" style="width:30%;float:right;">
                                <button id="btn-send-sms" type="button" class="btn btn-default" style="width:30%;float:right;" onclick="sms_count_down()">发送验证码</button>
                                <span id="sms-count-down"></span>
                            </p>
                        </div>
            	  	 <p id="a"></p>       	 
            	  		<input type="password" id="PwdNum1" name="password" required="required" class="password" pattern="^[a-zA-Z\d_]{6,20}$"  data-foolish-msg="密码是6-20位的字母、数字、下划线"  placeholder="请输入密码" required>
            	  	 <p id="b"></p>
            	  		<input type="password" id="PwdNum2" name="password2" class="password" data-equal-to="#PwdNum1" data-foolish-msg="请与上面输入的值一致" placeholder="请再次确认密码">
            	  	 <p id="c"></p>
            	     <button type="submit" >立即注册</button>
            </form>
            <div class="AddDiv">
            	<p style="font-size:12px;">已有账号？<span style="color: #FF730E;"><a href="{:U('User/login')}">立即登录</a></span></p>
            </div>
        </div>
		
        <!-- Javascript -->
        <script src="__PUBLIC__/assets/js/jquery-1.8.2.min.js"></script>
        <script src="__PUBLIC__/assets/js/supersized.3.2.7.min.js"></script>
        <script src="__PUBLIC__/assets/js/supersized-init.js"></script>
        <script src="__PUBLIC__/assets/js/scripts.js"></script>
        <script src="__PUBLIC__/assets/js/jquery.md5.js"></script>
       <script>
        function typechange() {
            var selectedValue = $("#doc-select-1").val();
            if (selectedValue == 3)
                window.location.href = "{:U('User/companyregist')}"
        }
        </script>
        <script type="text/javascript" charset="utf-8">

        // 验证码点击刷新  
            var captcha_img = $('#captcha-container').find('img')  
            var verifyimg = captcha_img.attr("src");  
            captcha_img.attr('title', '点击刷新');  
            captcha_img.click(function(){  
                if( verifyimg.indexOf('?')>0){  
                    $(this).attr("src", verifyimg+'&random='+Math.random());  
                }else{  
                    $(this).attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());  
                }  
            });

            //判断图片验证码
            $("#imgcode").blur(function(){
                var imgvalue = $('#imgcode').val();
                //console.log(imgvalue);
                $.ajax({
                    type: "post", 
                    dataType: "json",
                    url: "{:U('User/check_verif')}", 
                    data: {
                        imgval:imgvalue,
                    },
                    success:function(data){
                        //console.log(data);
                        if(data==1){
                            $("#imgcode").parent().append("<br/><b class='b'>验证码错误！</b>");
                            $("#btn-send-sms").attr('disabled','disabled');
                        }
                        if(data==0){
                            $(".b").empty();
                            $("#imgcode").parent().remove("b");
                            $("#btn-send-sms").removeAttr("disabled");
                        }
                        
                    }
                })
              
            });  
            /**
            * 发送短信验证码后，60秒倒计时
            */
            var seconds_left = 60;
            function sms_count_down(){
                if(seconds_left == 60 || seconds_left == 0){
                var code = $("#send-sms-code").val();
                var mobile = $("#send-sms-mobile").val();
                console.log(mobile);
                $.ajax({ 
                    type: "post", 
                    dataType: "json",
                    url: "{:U('User/registdo')}", 
                    data: {
                        tplid:'30316',
                        mobile:mobile,
                        code :code,
                    },
                })  
            }
                
                if(seconds_left > 0){
                    seconds_left = seconds_left-1;
                    //var b=new Date();
                    document.getElementById("btn-send-sms").innerHTML = seconds_left + "秒";
                    setTimeout("sms_count_down()",1000);
                } else {
                    //根据 http://stackoverflow.com/questions/7526601/setattributedisabled-false-changes-editable-attribute-to-false
                    // 不能为 setAttribute 设置任何值，都会变成 ”disabled“,要使用 removeAttribute
                    document.getElementById("btn-send-sms").removeAttribute("disabled");
                    document.getElementById("btn-send-sms").innerHTML = "重新发送";
                    document.getElementById("sms-count-down").innerHTML = "";
                }
            } 
        </script>
    </body>
  

</html>
